"use strict";
cc._RF.push(module, '471aeJiWaFDCoKDXjn8Nx4G', 'ScrollViewEvent');
// script/standar/utils/scrollView/ScrollViewEvent.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
/**
 * @classdesc 配合「ScrollViewPlus」组件使用的ScrollViewItem组件
 * @author caizhitao
 * @version 0.1.0
 * @since 2019-07-12
 * @description
 *
 * 用法：
 *
 *      1. 将本组件挂载在Item节点上
 * 		2. 在属性面板上指定事件数组回调，即可监听 Item 「进入」和「离开」ScrollView可视区域的事件
 *
 */
var ScrollViewEvent = /** @class */ (function (_super) {
    __extends(ScrollViewEvent, _super);
    function ScrollViewEvent() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.autoAlpha = false;
        _this.onEnterScorllViewEvents = [];
        _this.onExitScorllViewEvents = [];
        _this.onPositionChangeEvents = [];
        /**
         * 当前是否在展示中
         *
         * 1. 在进入和离开ScrollView期间，为true
         * 2. 在离开ScrolLView期间，为false
         */
        _this.isShowing = false;
        return _this;
    }
    /**
     * Item 进入 ScrollView 的时候回调
     */
    ScrollViewEvent.prototype.publishOnEnterScrollView = function () {
        if (this.autoAlpha) {
            this.node.opacity = 255;
        }
        if (this.onEnterScorllViewEvents.length == 0) {
            return;
        }
        this.onEnterScorllViewEvents.forEach(function (event) {
            event.emit([]);
        });
    };
    /**
     * Item 离开 ScrollView 的时候回调
     */
    ScrollViewEvent.prototype.publishOnExitScrollView = function () {
        if (this.autoAlpha) {
            this.node.opacity = 0;
        }
        if (this.onExitScorllViewEvents.length == 0) {
            return;
        }
        this.onExitScorllViewEvents.forEach(function (event) {
            event.emit([]);
        });
    };
    /**
     * Item 进入 ScrollView 后，位置发生移动时回调，离开ScrollView后不会回调
     *
     * @param xOffsetPercent 相对于 ScrollView 可视区域中心点，X的偏移量百分比，取值范围：[0, 1]。其中，0：为在可视区域最左边，1：为可视区域最右边
     * @param yOffsetPercent 相对于 ScrollView 可视区域中心点，Y的偏移量百分比，取值范围：[0, 1]。其中，0：为在可视区域最下边，1：为可视区域最上边
     */
    ScrollViewEvent.prototype.publishOnPositionChange = function (xOffsetPercent, yOffsetPercent) {
        if (this.onPositionChangeEvents.length == 0) {
            return;
        }
        this.onPositionChangeEvents.forEach(function (event) {
            event.emit([xOffsetPercent, yOffsetPercent]);
        });
    };
    __decorate([
        property({
            tooltip: "自动调整物体透明度",
        })
    ], ScrollViewEvent.prototype, "autoAlpha", void 0);
    __decorate([
        property({
            type: [cc.Component.EventHandler],
            tooltip: "进入ScrollView时回调"
        })
    ], ScrollViewEvent.prototype, "onEnterScorllViewEvents", void 0);
    __decorate([
        property({
            type: [cc.Component.EventHandler],
            tooltip: "离开ScrollView时回调"
        })
    ], ScrollViewEvent.prototype, "onExitScorllViewEvents", void 0);
    __decorate([
        property({
            type: [cc.Component.EventHandler],
            tooltip: "进入ScrollView之后，位置发生改变时回调"
        })
    ], ScrollViewEvent.prototype, "onPositionChangeEvents", void 0);
    ScrollViewEvent = __decorate([
        ccclass
    ], ScrollViewEvent);
    return ScrollViewEvent;
}(cc.Component));
exports.default = ScrollViewEvent;

cc._RF.pop();